﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.ComponentModel.Composition.Hosting;

namespace HVP.MEF.Tests
{
    [TestClass]
    public class HVPShellFixture
    {
        private CompositionContainer container;
        private Shell shell;

        [TestInitialize]
        public void Setup()
        {
            var catalog = new TypeCatalog(typeof (ItemView), typeof (TopicView),
                                          typeof (NoteView), typeof (LinkView),
                                          typeof (Viewer), typeof (Player), typeof (Shell),
                                          typeof(ShellViewModel));

            container = new CompositionContainer(catalog);
            shell = container.GetExportedValue<Shell>();
        }



        [TestMethod]
        public void WhenContainerQueriedShouldReturnShell()
        {
            Assert.IsNotNull(shell);
        }

 
        [TestMethod]
        public void WhenViewerIsCreatedShouldHaveAtLeastOneWidget()
        {
            Assert.AreNotEqual(0, shell.ViewModel.Viewer.Widgets.Count());
        }

        [TestMethod]
        public void WhenViewerIsCreatedShouldHaveOnePlayer()
        {
           int numberOfPlayers = 0;
           foreach ( IWidget widget in shell.ViewModel.Viewer.Widgets )
           {
              if ( widget is Player )
                 ++numberOfPlayers;
           }
           Assert.AreEqual( 1, numberOfPlayers );
        }


    }
}
